﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using Data.Abstract;
using System.Data.SQLite;
using System.Data;

namespace Data
{
    public class Visita : BaseObject<SimpleVisita>
    {
        #region Propiedades
      
        new public DalVisita Dal
        {
            get
            {
                if (_Dal == null) _Dal = new DalVisita();
                return (DalVisita)_Dal;
            }
        }

     
        #endregion
        #region Procedimientos
         public Visita(): base()
        {
            _Dal = new DalVisita();
        }
         public Visita(SimpleVisita Simple): base()
        {
            this._Simple = Simple;
            _Dal = new DalVisita(getConn());

        }
         public Visita(SimpleVisita Simple, SQLiteConnection conn )
             : base()
         {
             _Dal = new DalVisita(conn);
             _Simple = Simple;
         }
  
         
        #endregion
        #region Metodos

         //public SimpleVisita LoadByFecha(int NewsId, DateTime Fecha)
         //{
         //    this._Simple = new SimpleVisita();
         //    this._Simple.NewsId = NewsId;
         //    this._Dal = new DalVisita(getConn());
         //    DataTable dt =this.Dal.GetByFecha(Fecha);
         //    if(dt.Rows.Count==0)
         //    {
         //        this._Simple = null;
         //    }
         //    else
         //    {
         //        this._Simple.LoadByDataRow(dt.Rows[0]);
         //    }
         //    return this._Simple;
         //}
      
        public override void Insert()
        {
            this.Dal.Insert(this._Simple);
        }
        public override void Update()
        {
            this.Dal.Update(this._Simple);
        }
        public override void Delete()
        {
            throw new NotImplementedException();
        }

        #endregion
        SQLiteConnection getConn()
        {
            if (this._Simple != null)
            {
                //News n = new News();
                //n.Load(this._Simple.NewsId);
                //string tempDir =  Data.Configuration.Context.CurrentContext.GetTempPath(n.Simple.RespRandom, Data.Configuration.TipoBaseEnum.System).FullName;
                //System.IO.FileInfo fi = new System.IO.FileInfo(System.IO.Path.Combine(tempDir, "ClientInfo.db"));
                return new SQLiteConnection("data source=" );//+ fi.FullName);
            }
            return new SQLiteConnection();
        }

       
    }
}
